/*
 * @Date: 2023-01-22 05:37:33
 * @LastEditors: 恶名扬 2080156129@qq.com
 * @LastEditTime: 2023-01-22 08:52:53
 * @FilePath: \campus-repair-platform\server\schema\reception\repair.js
 */
/**
 * add_schema   提交报修申请
 * update_schema    修改报修单信息
 * record_add_schema    提交维修信息
 * record_update_schema 修改维修信息
 */

const joi = require("joi")

const { id, phone, p_name } = require("../common")
const problem = joi.string().min(5).max(255).error(new Error("问题描述格式有误"))
const place = joi.string().min(3).max(50).error(new Error("报修地点格式有误"))
const remark = joi.string().max(255).error(new Error("备注格式有误"))

exports.add_schema = {
  body: {
    type_id: id.required(),
    problem: problem.required(),
    place: place.required(),
    a_id: id.required(),
    phone,
    p_name
  }
}

exports.update_schema = {
  body: {
    id: id.required(),
    type_id: id,
    problem,
    place,
    phone,
    p_name,
    a_id: id,
  }
}

exports.record_add_schema = {
  body: {
    id: id.required(),
    remark,
    p_name
  },
}

exports.record_update_schema = {
  body: {
    id: id.required(),
    repair_number: id,
    remark, phone, p_name
  },
}

exports.return_schema = {
  body: {
    id: id.required().error(new Error('id式有误!')),
    isReturn: joi.boolean().required().error(new Error('是否退单格式有误!')),
    cause: joi.string().min(1).max(200).error(new Error("退回原因格式有误"))
  }
}

exports.query_schema = {
  query: {
    id,
    state: joi.number().min(-3).max(6).error(new Error("报修单状态格式有误")),
  },
}

exports.affirm_schema = {
  body: {
    id: id.required().error(new Error('id式有误!')),
    isAffirm: joi.boolean().required().error(new Error('是否完成有误!')),
    cause: joi.string().min(1).max(200).error(new Error("驳回原因格式有误"))
  }
}
